<!---->
<template>
    <div class="news_container">
        <component
            :is="active" 
            :userInfo="userInfo"
            :serviceOrder="serviceOrder"
            :goldInfoList="goldInfoList"
            :totalGoldInfo="totalGoldInfo"
            :total="total"
            @pageChange="pageChange"
            @tabChange="tabChange">
        </component>
    </div>
</template>
<script>
import gold from "../components/gold";
import info from "../components/info";
import goldrule from "../components/goldrule";
import {getUrlParams} from "../../../common/common";

const {token} = getUrlParams();

import {getServiceOrders,myGoldInfo,getTotalGoldInfo,getUserInfoOrder} from "../api/index";


export default {
    components:{
        info,
        gold,
        goldrule
    },
    data() {
        return {
            tableData:[],
            active: 'info',
            centralToken:token,
            serviceOrder:[],
            goldInfoList:[],
            totalGoldInfo:{},
            userInfo:{},
            total:0,
            params: {
                pageSize: 9,
                currentPage: 1,
                centralToken:token,
            }
        };
    },
    
    created() {
        this.getServiceOrders();
        this.myGoldInfo();
        this.getTotalGoldInfo();
        this.getUserInfoOrder();
    },
    
    methods: {
        tabChange(data){
            this.active = data;
        },
        // 页面变化
        pageChange(d){
            this.params.currentPage = d;
            this.myGoldInfo();
        },
        // 查询服务中订单
        getServiceOrders(){
            getServiceOrders(this.centralToken).then(res=>{
                this.serviceOrder = res.data || []
            })
        },
        //查询 实名信息 服务中订单
        getUserInfoOrder(){
            getUserInfoOrder(this.centralToken).then(res=>{
                this.userInfo = res.data||{};
                
            })
        },
        // 金币明细列表
        myGoldInfo(){
            myGoldInfo(this.params).then(res=> {
                this.goldInfoList = res.data.rows||[];
                this.total = res.data.total;
                console.log(this.total)
            })
        },
        // 金币总额信息
        getTotalGoldInfo(){
            getTotalGoldInfo(this.centralToken).then(res=>{
                // 总额
                this.totalGoldInfo = res.data.total[0]||{};
                // 昨日
               // this.yesterdayGold = res.data.goldList[0]||{};
            })
        }

    },
    
};
</script>

<style scoped lang="scss">
.news_container{
    width: 879px;
    height: 685px;
    background: #FFFFFF;
    margin: auto;
    //border: 1px solid #434448;
    font-family: Microsoft YaHei;
    padding: 0;
    box-sizing: border-box;
    font-size: 0;
    overflow: hidden;
}

</style>
